package com.concerneyes.mine.TabActivity.OrderView;

import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.widget.ScrollView;

import com.concerneyes.R;
import com.concerneyes.mine.adapter.MyOrderAdapter;

import java.util.ArrayList;
import java.util.List;

import common.AbsActivity;
import common.AbsBaseView;
import util.ActivityUtil;
import view.PagerSlidingTabStrip;

/**
 * 我的订单
 */

public class MyOrderActivity extends AbsActivity implements ViewPager.OnPageChangeListener {
    private PagerSlidingTabStrip tabStrip;
    private ViewPager viewpager;
    private MyOrderAdapter adapter;
    @Override
    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(R.layout.activity_order);
        String title = getIntent().getExtras().getString("title");
        setTitle(title);
        initView();
    }

    private void initView() {
        tabStrip = (PagerSlidingTabStrip) findViewById(R.id.tabStrip_order);
        tabStrip.setTextColorResource(R.color.white);
        tabStrip.setTextSize(ActivityUtil.sp2px(12));
        tabStrip.setOnPageChangeListener(this);
        viewpager = (ViewPager) findViewById(R.id.viewpager_order);
        viewpager.setOnPageChangeListener(this);
        List<String> titleList = new ArrayList<String>();
        String[] order_style = getResources().getStringArray(R.array.order_me_style);
        titleList.add(order_style[0]);
        titleList.add(order_style[1]);
        titleList.add(order_style[2]);
        titleList.add(order_style[3]);
        titleList.add(order_style[4]);
        titleList.add(order_style[5]);

        adapter = new MyOrderAdapter(this, titleList);
        viewpager.setAdapter(adapter);
        tabStrip.setViewPager(viewpager);
    }
    @Override
    protected void onResume() {
        super.onResume();
        for (int i = 0; i < 5; i++) {
            AbsBaseView view = adapter.getView(i);
            view.loadData("1");
        }

    }
    @Override
    public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

    }

    @Override
    public void onPageSelected(int position) {
        AbsBaseView view = adapter.getView(position);
        view.loadData("1");
    }

    @Override
    public void onPageScrollStateChanged(int state) {

    }
}
